<template>
  <div>
    <el-form ref="form" :model="form" label-width="100px">
      <el-form-item label="店铺名称">
        <el-input
          placeholder="请输入店铺名称"
          v-model="form.name"
          clearable
          style="width: 500px"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="店铺地址">
        <el-input placeholder="请输入店铺地址" v-model="form.address" clearable>
        </el-input>
      </el-form-item>
      <el-form-item label="店铺电话">
        <el-input placeholder="请输入店铺电话" v-model="form.tel" clearable>
        </el-input>
      </el-form-item>
      <el-form-item label="营业状态">
        <el-radio-group v-model="form.business">
          <el-radio label="正在营业中"></el-radio>
          <el-radio label="暂停营业中"></el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="营业时间">
        <el-input placeholder="请输入营业时间" v-model="form.time" clearable>
        </el-input>
      </el-form-item>
      <el-form-item label="店铺状态">
        <el-radio-group v-model="form.status">
          <el-radio label="申请中"></el-radio>
          <el-radio label="已通过"></el-radio>
          <el-radio label="未通过"></el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="是否可以配送">
        <el-switch v-model="form.hasDistribution"></el-switch>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">确认新增</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { createNamespacedHelpers } from "vuex";
const { mapMutations } = createNamespacedHelpers("stores");
export default {
  data() {
    return {
      form: {
        name: "",
        address: "",
        tel: "",
        business: "",
        time: "",
        status: "",
        hasDistribution: false,
      },
    };
  },
  methods: {
    ...mapMutations(["addStores"]),
    onSubmit() {
      this.form.business = this.form.business === "正在营业中" ? true : false;
      const data = this.form;
      this.addStores(data);
      this.$alert("店铺新增成功", "系统提示", {
        confirmButtonText: "确定",
        callback: () => {
          this.$router.history.push("/info/storeList");
        },
      });
    },
  },
};
</script>
<style scoped></style>
